// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境

// 云函数入口函数
exports.main = async (event, context) => {
  var key = "";
  if (event.type == "ticket") {
    key = "ticket_number";
  } else if (event.type == "user_id") {
    key = "u_id";
  }
  else if (event.type == "student_id") {
    key = "s_id";
  }
  else if (event.type == "institution_id") {
    key = "i_id";
  }
  else {
    key = "_id";
  }
  return cloud.callFunction({
    name: "model_ticket",
    data: {
      op: "select",
      key: key,
      value: event.value
    }
  }).then(res => { return res.result.data; })
}